package bjut.zrpc.core.optimization.bean;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.concurrent.Semaphore;

/**
 * @Author: zhuzhiming
 * @Date: 2022/6/23 21:33
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ZRpcServiceBean {

    private String group;
    private String version;
    private int retry = -1;
    private boolean mock = false;
    private String mockMethod = "bjut.zrpc.core.optimization.mock.DefaultMock";
    private int timeout = 1000;
    private int increase = 0;
    private Object service;
    private boolean sentinel = true;
    private int duration = 3000;
    private int exceptionCount = 5;
    private int inTime = 3000;
    private boolean limit = false;
    private int limitCount = 10;
    private int inLimitTime = 1000;
    private int limitDuration = 3000;
    private boolean concurrencyControl;
    private int concurrency;
    private Semaphore semaphore;
    private boolean needInterceptor;
    private String interceptor;

    public String getRpcServiceName() {
        String serviceName = this.service.getClass().getInterfaces()[0].getCanonicalName();
        return serviceName + "." + this.group + "." + this.version;
    }

}
